/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ui;

import database.MembroDB;
import database.PessoaDB;
import database.VisitanteDB;
import java.awt.Color;
import java.sql.Date;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import model.Membro;
import model.Pessoa;
import model.Visitante;

/**
 *
 * @author Alana
 */
public class MemberManagement extends javax.swing.JFrame {
    
    /**
     * Creates new form MemberManagement
     */
    public MemberManagement() {
        initComponents();
        this.setLocationRelativeTo(null);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents()
    {

        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        dCasamento = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jTextField7 = new javax.swing.JTextField();
        jCheckBox1 = new javax.swing.JCheckBox();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jTextField8 = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        dNascimento = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        estadoCivil = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        observacoes = new javax.swing.JTextArea();
        jLabel12 = new javax.swing.JLabel();
        ativo = new javax.swing.JCheckBox();
        buscar = new javax.swing.JButton();
        cadastrar = new javax.swing.JButton();
        remover = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Gerenciamento de Membros");

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel1.setText("Nome");

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel4.setText("Endereço");

        jTextField4.setForeground(new java.awt.Color(153, 153, 153));
        jTextField4.setText("Separe por \";\" os telefones.");
        jTextField4.addMouseListener(new java.awt.event.MouseAdapter()
        {
            public void mouseClicked(java.awt.event.MouseEvent evt)
            {
                jTextField4MouseClicked(evt);
            }
        });
        jTextField4.addFocusListener(new java.awt.event.FocusAdapter()
        {
            public void focusLost(java.awt.event.FocusEvent evt)
            {
                jTextField4FocusLost(evt);
            }
        });

        dCasamento.setText("dd/mm/aaaa");
        dCasamento.setForeground(new java.awt.Color(153, 153, 153));
        dCasamento.addMouseListener(new java.awt.event.MouseAdapter()
        {
            public void mouseClicked(java.awt.event.MouseEvent evt)
            {
                dCasamentoMouseClicked(evt);
            }
        });
        dCasamento.addFocusListener(new java.awt.event.FocusAdapter()
        {
            public void focusLost(java.awt.event.FocusEvent evt)
            {
                dCasamentoFocusLost(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel5.setText("Telefones");

        jCheckBox1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jCheckBox1.setText("Visitante");
        jCheckBox1.addChangeListener(new javax.swing.event.ChangeListener()
        {
            public void stateChanged(javax.swing.event.ChangeEvent evt)
            {
                jCheckBox1StateChanged(evt);
            }
        });

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel8.setText("Data de Casamento");

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel9.setText("Email");

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel10.setText("Estado Civil");

        dNascimento.setText("dd/mm/aaaa");
        dNascimento.setForeground(new java.awt.Color(153, 153, 153));
        dNascimento.addMouseListener(new java.awt.event.MouseAdapter()
        {
            public void mouseClicked(java.awt.event.MouseEvent evt)
            {
                dNascimentoMouseClicked(evt);
            }
        });
        dNascimento.addFocusListener(new java.awt.event.FocusAdapter()
        {
            public void focusLost(java.awt.event.FocusEvent evt)
            {
                dNascimentoFocusLost(evt);
            }
        });

        jLabel11.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel11.setText("Observações");

        estadoCivil.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        estadoCivil.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Solteiro(a)", "Casado(a)", "Divorciado(a)", "Viuvo(a)" }));

        observacoes.setColumns(20);
        observacoes.setRows(5);
        observacoes.setEnabled(false);
        jScrollPane1.setViewportView(observacoes);

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel12.setText("Data de Nascimento");

        ativo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        ativo.setText("Ativo");

        buscar.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        buscar.setText("Buscar");
        buscar.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                buscarActionPerformed(evt);
            }
        });

        cadastrar.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        cadastrar.setText("Cadastrar");
        cadastrar.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                cadastrarActionPerformed(evt);
            }
        });

        remover.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        remover.setText("Remover");
        remover.setEnabled(false);
        remover.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                removerActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jCheckBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGap(10, 10, 10)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel4)
                                .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, 600, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel5)
                                .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 600, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel9)
                                .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, 600, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addComponent(jLabel12)
                                    .addGap(127, 127, 127)
                                    .addComponent(jLabel11))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(dNascimento, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel8)
                                        .addComponent(dCasamento, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jLabel10))
                                    .addGap(120, 120, 120)
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 350, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(estadoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(ativo))
                                    .addGap(141, 141, 141)
                                    .addComponent(remover, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(buscar, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(cadastrar, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 600, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(8, 8, 8)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jCheckBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel4)
                .addGap(9, 9, 9)
                .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(2, 2, 2)
                .addComponent(jLabel9)
                .addGap(15, 15, 15)
                .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(dNascimento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, 0)
                        .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, 0)
                        .addComponent(dCasamento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, 0)
                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(buscar, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(cadastrar, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(remover, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(estadoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(7, 7, 7)
                        .addComponent(ativo)))
                .addGap(59, 59, 59))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 450, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        jPanel1.getAccessibleContext().setAccessibleName("");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cadastrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cadastrarActionPerformed
        // TODO add your handling code here:
        String nome = new String(jTextField5.getText());
        String end = new String(jTextField7.getText());
        String tels = new String(jTextField4.getText());
        ArrayList<String> tel = new ArrayList<String>();
//        String inter = new String();
//        for(int i =0;i<tels.length();i++) {
//            if(tels.charAt(i) == ';') {
//                tel.add(inter);
//                inter = new String();
//            }
//            inter = inter + tels.charAt(i);
//        }
        int i, j;
        for (i = 0; i < tels.length(); i = j + 1)
        {
            for (j = i; j < tels.length() && tels.charAt(j) != ';'; j++);
            String fone = tels.substring(i, j);
            tel.add(fone);
        }
        String email = new String(jTextField8.getText());
        if(jCheckBox1.isSelected()) {
            String obs = new String(observacoes.getText());
            Visitante vis = new Visitante(obs,nome,end,email,tel);
            if (VisitanteDB.insert(vis))
            {
                JOptionPane.showMessageDialog(null, "Visitante cadastrado no catálogo!");
            }
            else
            {
                JOptionPane.showMessageDialog(null, "Ops! Alguma coisa deu errado, verifique se os campos estão preenchidos corretamente e a conectividade com o banco de dados");
            }
        }
        else {
            String datanasc = new String(dNascimento.getText());
            String d = new String("");
            d = d + datanasc.charAt(0)+datanasc.charAt(1);
            int dia = Integer.parseInt(d);
            String m = new String("");
            m = m + datanasc.charAt(3)+datanasc.charAt(4);
            int mes = Integer.parseInt(m);
            String a = new String("");
            a = a + datanasc.charAt(6)+datanasc.charAt(7)+datanasc.charAt(8)+datanasc.charAt(9);
            int ano = Integer.parseInt(a);
            Date datanas = new Date(ano,mes,dia);
            
            String datacas = new String(dCasamento.getText());
            d = new String("");
            d = d + datacas.charAt(0)+datacas.charAt(1);
            dia = Integer.parseInt(d);
            m = new String("");
            m = m + datacas.charAt(3)+datacas.charAt(4);
            mes = Integer.parseInt(m);
            a = new String("");
            a = a + datacas.charAt(6)+datacas.charAt(7)+datacas.charAt(8)+datacas.charAt(9);
            ano = Integer.parseInt(a);
            Date dataca = new Date(ano,mes,dia);
            
            String estadociv = new String((String) estadoCivil.getSelectedItem());
            boolean ativ = ativo.isSelected();
            
            Membro mem = new Membro(ativ,datanas,dataca,estadociv,nome,end,email,tel);
            if (MembroDB.insert(mem))
            {
                JOptionPane.showMessageDialog(null, "Membro cadastrado no catálogo!");
            }
            else
            {
                JOptionPane.showMessageDialog(null, "Ops! Alguma coisa deu errado, verifique se os campos estão preenchidos corretamente e a conectividade com o banco de dados");
            }
        }
    }//GEN-LAST:event_cadastrarActionPerformed

    private void buscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buscarActionPerformed

        String nome = new String(jTextField5.getText());
       
        if(jCheckBox1.isSelected()) {
            ArrayList<Visitante> visis = VisitanteDB.search(nome);
            
//            //TESTE
//            ArrayList<Visitante> visis = new ArrayList<Visitante>();            
//            ArrayList<String> tel = new ArrayList<String>();        
//            Visitante p = new Visitante ("obs", "alana", "end", "email", tel);
//            Visitante p2 = new Visitante ("obs22", "alana", "end", "email", tel);
//            visis.add(p);
//            visis.add(p2);
//            //
            
            Consulta con = new Consulta(this, visis);
            con.setLocationRelativeTo(null);
            con.setVisible(true);
            
    }
      else {
            ArrayList<Membro> membs = MembroDB.search(nome);
//            ArrayList<Membro> membs = new ArrayList<Membro>();
            if(membs.size()==1) {
                setCampos(membs.get(0));
            }
            Consulta con = new Consulta(membs,this);
            con.setVisible(true);
            con.setLocationRelativeTo(null);
            con.isvisit = 0;
        }
        
//        remover.setEnabled(true);
    }//GEN-LAST:event_buscarActionPerformed

    public void setCampos(Visitante vis) {
        jCheckBox1.setSelected(true);
        jTextField5.setText(vis.getNome());
        jTextField7.setText(vis.getEndereco());
        ArrayList<String> tel = vis.getTelefones();
        String tels = new String("");
        if(tel.size()!=0) {
            tels = tel.get(0);
            for(int i=1;i<tel.size();i++) {
                tels = tels + ";"+ tel.get(i);
            }
        }
        jTextField4.setText(tels);
        observacoes.setText(vis.getObservacoes());
    }
    
    public void setCampos(Membro mem) {
        jCheckBox1.setSelected(false);
        jTextField5.setText(mem.getNome());
        jTextField7.setText(mem.getEndereco());
        ArrayList<String> tel = mem.getTelefones();
        String tels = new String("");
        if(tel.size()!=0) {
            tels = tel.get(0);
            for(int i=1;i<tel.size();i++) {
                tels = tels + ";"+ tel.get(i);
            }
        }
        jTextField4.setText(tels);
        dNascimento.setText(mem.getdNascimento().toString());
        dCasamento.setText(mem.getdCasamento().toString());
        estadoCivil.setSelectedItem(mem.getEstadoCivil());
        ativo.setSelected(mem.getAtividade());
    }
    
    
    private void dNascimentoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_dNascimentoFocusLost
        // TODO add your handling code here:
        if(dNascimento.getText().equals("")){
            dNascimento.setText("dd/mm/aaaa");
            dNascimento.setForeground(new java.awt.Color(153, 153, 153));
        }
    }//GEN-LAST:event_dNascimentoFocusLost

    private void dNascimentoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_dNascimentoMouseClicked
        // TODO add your handling code here:
        if(dNascimento.getText().equals("dd/mm/aaaa")){
            dNascimento.setText("");
            dNascimento.setForeground(Color.BLACK);
        }
    }//GEN-LAST:event_dNascimentoMouseClicked

    private void jCheckBox1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBox1StateChanged
        // TODO add your handling code here:
        if(jCheckBox1.isSelected()){
            dNascimento.setEnabled(false);
            dNascimento.setText("dd/mm/aaaa");
            dNascimento.setForeground(new java.awt.Color(153, 153, 153));
            dCasamento.setEnabled(false);
            dCasamento.setText("dd/mm/aaaa");
            dCasamento.setForeground(new java.awt.Color(153, 153, 153));
            estadoCivil.setEnabled(false);
            observacoes.setEnabled(true);
            ativo.setEnabled(false);
            ativo.setSelected(false);
        }else{
            dNascimento.setEnabled(true);
            dCasamento.setEnabled(true);
            estadoCivil.setEnabled(true);
            observacoes.setEnabled(false);
            observacoes.setText("");
            ativo.setEnabled(true);
        }

    }//GEN-LAST:event_jCheckBox1StateChanged

    private void dCasamentoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_dCasamentoFocusLost
        if(dCasamento.getText().equals("")){
            dCasamento.setText("dd/mm/aaaa");
            dCasamento.setForeground(new java.awt.Color(153, 153, 153));
        }
    }//GEN-LAST:event_dCasamentoFocusLost

    private void dCasamentoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_dCasamentoMouseClicked
        if(dCasamento.getText().equals("dd/mm/aaaa")){
            dCasamento.setText("");
            dCasamento.setForeground(Color.BLACK);
        }
    }//GEN-LAST:event_dCasamentoMouseClicked

    private void jTextField4FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTextField4FocusLost
        if(jTextField4.getText().equals("")){
            jTextField4.setText("Separe por \";\" os telefones.");
            jTextField4.setForeground(new java.awt.Color(153, 153, 153));
        }
    }//GEN-LAST:event_jTextField4FocusLost

    private void jTextField4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTextField4MouseClicked
        if(jTextField4.getText().equals("Separe por \";\" os telefones.")){
            jTextField4.setText("");
            jTextField4.setForeground(Color.BLACK);
        }
    }//GEN-LAST:event_jTextField4MouseClicked

    private void removerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removerActionPerformed
        // TODO add your handling code here:
        String nome = new String(jTextField5.getText());
        String end = new String(jTextField7.getText());
       
        if(jCheckBox1.isSelected()) {
            VisitanteDB.delete(nome, end);
        }
        else {
            MembroDB.delete(nome, end);
        }
        
//        remover.setEnabled(false);
    }//GEN-LAST:event_removerActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MemberManagement.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MemberManagement.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MemberManagement.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MemberManagement.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                MemberManagement m = new MemberManagement();
                m.setLocationRelativeTo(null);
                m.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox ativo;
    private javax.swing.JButton buscar;
    private javax.swing.JButton cadastrar;
    private javax.swing.JTextField dCasamento;
    private javax.swing.JTextField dNascimento;
    private javax.swing.JComboBox estadoCivil;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JTextField jTextField8;
    private javax.swing.JTextArea observacoes;
    private javax.swing.JButton remover;
    // End of variables declaration//GEN-END:variables
}
